﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BLToolkit.EditableObjects;

namespace AndreySmirnov.BLToolkitUtils.VSPackage.Model.ViewModel
{
	public class ConnectionViewModel : ViewModelBase
	{
		private BLTConnectionInfo m_connectionInfo;
		public BLTConnectionInfo ConnectionInfo
		{
			get { return m_connectionInfo; }
			set
			{
				m_connectionInfo = value;
				NotifyAllPropsChanged();
			}
		}

		public BLTConnectionCredentialsType CredentialsType
		{
			get { return ConnectionInfo.CredentialsType; }
			set
			{
				ConnectionInfo.CredentialsType = value;
				ConnectionInfo.CredentialsData = string.Empty;
				NotifyPropertyChange("CredentialsType");
			}
		}

		public string Server
		{
			get { return ConnectionInfo.Server; }
			set
			{
				ConnectionInfo.Server = value;
				NotifyPropertyChange("Server");
			}
		}

		public string DatabaseName
		{
			get { return ConnectionInfo.DatabaseName; }
			set
			{
				ConnectionInfo.DatabaseName = value;
				NotifyPropertyChange("DatabaseName");
			}
		}

	    public bool InjectConnStringIntoDefaultCtor
	    {
	        get
	        {
	            return ConnectionInfo.InjectConnStringIntoDefaultCtor;
	        }
            set
            {
                ConnectionInfo.InjectConnStringIntoDefaultCtor = value;
                NotifyPropertyChange("InjectConnStringIntoDefaultCtor");
            }
	    }

		private ClearTextConnInfoViewModel m_clearTextVM;

		public ClearTextConnInfoViewModel ClearTextVM
		{
			get { return m_clearTextVM ?? (m_clearTextVM = new ClearTextConnInfoViewModel(ConnectionInfo)); }
			set { m_clearTextVM = value; }
		}

		private PromptConnInfoViewModel m_promptVM;
		public PromptConnInfoViewModel PromptVM
		{
			get { return m_promptVM ?? (m_promptVM = new PromptConnInfoViewModel(ConnectionInfo)); }
			set { m_promptVM = value; }
		}

		private EncryptedConnInfoViewModel m_encryptedVM;
		public EncryptedConnInfoViewModel EncryptedVM
		{
			get { return m_encryptedVM ?? (m_encryptedVM = new EncryptedConnInfoViewModel(ConnectionInfo)); }
			set { m_encryptedVM = value; }
		}
	}
}
